<template>
  <j-modal :footer="null"
    :title="title"
    :visible="visible"
           :width="600"
    :maskClosable="false"
    :fullscreen="false"
    @ok="handleOk"
    :okButtonProps="{}"
    @cancel="handleCancel">
    <a-table rowKey="id" bordered size="middle" :columns="columns" :dataSource="dataSource" :pagination="false">
      <div slot="type" slot-scope="text, record">
        {{ text == 1 ? '符合性审查项' : '评分标准' }}
      </div>
      <div slot="action" slot-scope="text, record">
        <a-button @click="rollBack(record.id)" type="link" size="small">回退</a-button>
      </div>
    </a-table>
  </j-modal>
</template>

<script>
import { getAction } from '@/api/manage'
import { Modal } from 'ant-design-vue'
import { axios } from '@/utils/request'

export default {
  name: 'RollBackModal',
  data () {
    return {
      title: '回退',
      width: 800,
      visible: false,
      columns: [
        {
          title: '名称',
          align: 'center',
          dataIndex: 'businessName',
          width:100
        },
        {
          title: '类型',
          align: 'center',
          dataIndex: 'type',
          width: 100,
          scopedSlots: { customRender: 'type' }
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          width: 147,
          scopedSlots: { customRender: 'action' }
        }],
      url: {
        rollBack: '/exPingbiao/exPingbiaoExpert/rollBack',
      },
      dataSource: [],
      sectionId: null
    }
  },
  methods: {
    showModal (sectionId, list) {
      this.visible = true
      this.sectionId = sectionId
      this.dataSource=  list;
    },
    rollBack(businessId){
      let that = this;
      Modal.confirm({
        title: '确认',
        content: '确定要回退吗，确认后该操作不可取消？',
        okText: '确认',
        cancelText: '取消',
        onOk: async () => {
          let params = {
            sectionId: that.sectionId,
            businessId
          }
          getAction(that.url.rollBack, params)
            .then((res) => {
              that.$emit('ok')
              that.close();
            })
            .finally(() => {})
        },
      })

    },
    close () {
      this.$emit('close')
      this.visible = false
    },
    handleOk () {
    },
    submitCallback () {
      this.$emit('ok')
      this.visible = false
    },
    handleCancel () {
      this.$emit('ok')
      this.close()
    }
  }
}
</script>

<style scoped>
</style>
